package com.party.mobile.web.controller.competition;

import com.party.common.utils.PartyCode;
import com.party.common.utils.StringUtils;
import com.party.core.model.competition.CompetitionProject;
import com.party.core.service.competition.ICompetitionProjectService;
import com.party.mobile.web.dto.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 赛事成绩项目
 * Created by yifeng
 *
 * @date 2018/4/20 0020
 * @time 下午 13:58
 */
@Controller
@RequestMapping("/competition/project")
public class CompetitionProjectController {
    @Autowired
    private ICompetitionProjectService competitionProjectService;

    /**
     * 根据项目id获取项目
     *
     * @param projectId 项目id
     * @return
     */
    @ResponseBody
    @RequestMapping("findMemberIdById")
    public AjaxResult findMemberIdById(String projectId) {
        if (StringUtils.isEmpty(projectId)) {
            return AjaxResult.error(PartyCode.PARAMETER_ILLEGAL, "项目id不能为空");
        }
        try {
            CompetitionProject project = competitionProjectService.get(projectId);
            if (project == null) {
                return AjaxResult.error(PartyCode.IS_NO_DATA, "项目不存在");
            }
            return AjaxResult.success((Object) project.getCreateBy());
        } catch (Exception e) {
            return AjaxResult.error(100, "根据项目id获取项目异常");
        }
    }
}
